package com.manage.dao;

import com.manage.domain.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface IDeptDao {

    @Select("select * from dept order by update_time desc")
    List<Dept> list();

    @Select({
            "<script>",
            "select * from dept",
            "<where>",
            "<if test=\"name != null and name != ''\">name like concat('%',#{name},'%')</if>",
            "</where>",
            "order by update_time desc",
            "</script>"
    })
    List<Dept> listByName(@Param("name") String name);

    @Insert("insert into dept(name) values(#{name})")
    void insert(Dept dept);

    @Update("update dept set name=#{name} where id=#{id}")
    void update(Dept dept);

    @Delete("delete from dept where id=#{id}")
    void deleteById(Integer id);
}


